package com.xtc.netty.io.nio.channel;

import java.io.FileInputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class FileInputDemo {

    public static void main(String[] args) {
        try {
            String filePath = "C:\\Users\\Administrator\\Desktop\\百度网盘会员\\bufferDemo.txt";

            FileInputStream fis = new FileInputStream(filePath);

            FileChannel fisChannel = fis.getChannel();

            ByteBuffer buffer = ByteBuffer.allocate(1024);

            fisChannel.read(buffer);

            buffer.flip();

            while (buffer.remaining() > 0) {
                System.out.println(buffer.get());
            }
            fis.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
